package cn.tedu.zhyl.system.controller;

import cn.tedu.zhyl.base.response.JsonResult;
import cn.tedu.zhyl.system.pojo.dto.SysDeptQuery;
import cn.tedu.zhyl.system.pojo.vo.SysDeptVo;
import cn.tedu.zhyl.system.service.SysDeptService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Slf4j
@Api(tags = "部门管理")
@RestController
@RequestMapping("/system/dept/")
public class SysDeptController {
    @Autowired
    private SysDeptService sysDeptService;
    @PostMapping("getList")
    public JsonResult<List<SysDeptVo>> getDeptList(@RequestBody Map<String,List<String>> query){
        log.debug("查询部门列表，参数：{}",query);
        log.debug("部门名数组为:{}",query.get("deptNo"));
        List<String> deptNos = query.get("deptNo");
        List<String> list = sysDeptService.findDeptList(deptNos);
        return JsonResult.ok(list);
    }
    @PostMapping("get/tree")
    public JsonResult<List<SysDeptVo>> getTreeDeptList(){
        List<SysDeptVo> list = sysDeptService.getTreeDeptList();
        return JsonResult.ok(list);
    }

    @GetMapping("select")
    public JsonResult<List<SysDeptVo>> selectAll(){
        List<SysDeptVo> list = sysDeptService.select();
        log.debug("查询部门列表，结果：{}",list);
        return JsonResult.ok(list);
    }

}
